package ar.edu.caece.compiler.grammar.factories;

import ar.edu.caece.compiler.grammar.AbstractTokenVisitorFactory;
import ar.edu.caece.compiler.grammar.TokenVisitor;

public class OP1Factory extends AbstractTokenVisitorFactory {

	private static OP1Factory INSTANCE;
	
	private OP11Factory op11Factory;
	private OP12Factory op12Factory;
	private OP13Factory op13Factory;
	private OP14Factory op14Factory;
	
	public static OP1Factory getInstance() throws Exception {
		if(INSTANCE==null) INSTANCE = new OP1Factory();
		return INSTANCE;
	}
	
	private Initializer initializer = new Initializer() {
		
		@Override
		public void init() {
			initializer = NoOperationInitializer.getInstance();
			op11Factory = OP11Factory.getInstance();
			op12Factory = OP12Factory.getInstance();
			op13Factory = OP13Factory.getInstance();
			op14Factory = OP14Factory.getInstance();
		}
	};
	
	private OP1Factory() throws Exception {

	}
	
	@Override
	public TokenVisitor makeChainedVisitor(
			final TokenVisitor siguiente) throws Exception {
		initializer.init();

		return op11Factory.makeChainedVisitor(op12Factory.makeChainedVisitor(op13Factory.makeChainedVisitor(op14Factory.makeChainedVisitor(siguiente))));
	
	}
	@Override
	public TokenVisitor makeVisitor() throws Exception {
		initializer.init();

		return op11Factory.makeChainedVisitor(op12Factory.makeChainedVisitor(op13Factory.makeChainedVisitor(op14Factory.makeVisitor())));
	}
	
	
}
